#include<iostream>

using namespace std;

int main()
{
	string processed, raw, need;
	cin >> processed >> raw >> need;
	char a[26], b[26];
	int nowlength = 0;
	for (int i = 0; i < processed.size(); i++)
	{
		bool iscontain = false;
		for (int j = 0; j < nowlength; j++)
		{
			if(a[j] == processed[i])
			{
				if (b[j] != raw[i])
				{
					cout << "Failed";
					return 0;
				}
				iscontain = true;
				break;
			}
		} 
		if (iscontain == false)
		{

			for (int k = 0; k < nowlength; k++)
			{
				if (b[k] == raw[i])
				{
					cout << "Failed";
					return 0;
				}
			}
			a[nowlength] = processed[i];
			b[nowlength] = raw[i];
			nowlength++;
		}
	}
	if (nowlength != 26)
	{
		cout << "Failed";
		return 0;
	}
	for (int i = 0; i < need.size(); i++)
	{
		for (int j = 0; j < nowlength; j++)
		{
			if (a[j] == need[i]) cout << b[j];
		}
	}
	return 0;
}